package cn.dankal.flyaudio.adapter;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.Map;

import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewAdapter;
import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewHolder;
import cn.dankal.basiclib.pojo.CategoryListEntity;
import cn.dankal.basiclib.util.ActivityUtils;
import cn.dankal.flyaudio.R;
import cn.dankal.flyaudio.model.StoreMenuModel;
import cn.dankal.flyaudio.store.ClassificationActivity;

public class StoreMenuAdapter extends BaseRecyclerViewAdapter<CategoryListEntity> {
    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.item_store_menu;
    }

    @Override
    protected BaseRecyclerViewHolder getViewHolder(ViewGroup parent, View rootView, int viewType) {
        return new ViewHolder(rootView);
    }

    public class ViewHolder extends BaseRecyclerViewHolder<CategoryListEntity> {

        public ViewHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void onBindData(CategoryListEntity data, int position) {
            setImageUrl(R.id.iv_menu,data.getImgUrl());
            setText(R.id.tv_title,data.getName());
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(ActivityUtils.getTopActivity(),ClassificationActivity.class);
                    intent.putExtra("category_uuid",data.getUuid());
                    ActivityUtils.startActivity(intent);
                }
            });
        }
    }
}
